package com.link.base.base.qrcode.controller;

import com.link.core.cllog.LCLogger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.OutputStream;

/**
 * @author unknown
 * @date unknown
 * @comments 二维码
 */
@Controller
@RequestMapping("base/qrCode")
public class QRCodeController {

    @RequestMapping(value = "{para1}/{para2}/qrCode.jpg", method = RequestMethod.GET)
    @ResponseBody
    public void queryAccount(@PathVariable String para1, @PathVariable String para2, HttpSession session,
                             HttpServletRequest request, HttpServletResponse response) {
        // 设置返回内容格式
        response.setContentType("image/jpeg");
        try {
            // 用该文件创建一个输入流
            //InputStream in = new FileInputStream(file);
            // 创建输出流
            OutputStream os = response.getOutputStream();
            os.flush();
            os.close();
        } catch (Exception e) {
            LCLogger.withException(e);
        }
    }

    @RequestMapping(value = "survey1.jsp", method = RequestMethod.GET)
    @ResponseBody
    public ModelAndView querysurvey1(String para1, String para2, HttpSession session,
                                     HttpServletRequest request, HttpServletResponse response) {
        ModelAndView mav = new ModelAndView();
        mav.setViewName("survey/survey1");
        mav.addObject("para1", para1);
        mav.addObject("para2", para2);
        return mav;
    }
}
